
package Action;

import Object.BienToanCuc;
import UI.Game;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MouseInput implements MouseListener {
    private Game game;
    private boolean moused = false;
    
    public MouseInput(Game _game) {
        game = _game;
    }
    
    @Override
    public void mousePressed (MouseEvent e) {
        //game.mousePressed(e);
        int mx = e.getX();
        int my = e.getY();
        
        if(mx >= BienToanCuc.xgio && mx <= (BienToanCuc.xgio + 100)) {
            if(my >= BienToanCuc.ygio && my <= (BienToanCuc.ygio + 81)) {
                moused = true;
            }
        }
    }

    @Override
    public void mouseEntered (MouseEvent e) {
        //game.mouseEntered(e);
        if(moused == true) {
            game.giotrung.setX(e.getX());
        }
    }

    @Override
    public void mouseReleased (MouseEvent e) {
        moused = false;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        int mx = e.getX();
        int my = e.getY();
        if(mx >= 170 && mx <= 320) {
            if(my >= 400 && my <= 450) {
                game.state = game.state.GAME;
            }
        }
    }

    @Override
    public void mouseExited(MouseEvent e) {
    }
    
}
